package cs235.xml;

public class XMLText extends XMLNode implements Text {

    private String data;
    
    public XMLText(){
        this(null);
    }

    public XMLText(Node parent) {
        super(TEXT_NODE, parent);
    }
    

    @Override
    public String getData() {
        if (data == null) {
            throw new IllegalStateException("Data has not been set");
        }
        return data;
    }
    
    @Override
    public void setData(String data) {
        if (data == null) {
            throw new IllegalArgumentException("data cannot be null");
        }
        this.data = data;
    }
    
    @Override
    public String toString(){
        if (data == null) {
            throw new IllegalArgumentException("data cannot be null");
        }
        return data;
    }

}
